<template>
  <div class="app-container">
    <list-admin
      v-model="list"
      :entity-conf="entity"
      :list-display="fields"
      :list-filter="filters"
      :disabled-actions="disabled"
      :query="query"
      :config="config"
      :actions="actions"
    >
      <template v-slot:titleText>
        <span>富友POS机&台码</span>
      </template>
    </list-admin>
  </div>
</template>

<script>
import ListAdmin from '@/components/EasyAdmin/ListAdmin'
import admin from '@/config'

export default {
  components: { ListAdmin },
  data() {
    return {
      entity: '',
      alias: '',
      list: [],
      config: {},
      fields: [],
      filters: null,
      params: this.$route.query
    }
  },
  created() {
    // Load entities data
    this.alias = 'FuiouPosDevice'

    if (!Object.keys(admin.entities).includes(this.alias)) {
      console.log('NO!')
    } else {
      console.log(admin.entities)
      this.config = admin.entities[this.alias]
      this.entity = Object.keys(this.config).includes('entity') ? this.config.entity : this.alias
      this.disabled = this.config.list.disabled_actions
      this.actions = this.config.list.actions
      this.query = this.config.list.query
      this.filters = this.config.list.list_filter
      this.fields = this.config.list.list_display
    }
  }
}
</script>
